//
//  QRScanView.swift
//  TestDemo
//
//  Created by 赵洋 on 2017/6/6.
//  Copyright © 2017年 赵洋. All rights reserved.
//

import UIKit

class QRScanView: UIView {
    private var scanRect:CGRect
   
    init(ScanRect rect:CGRect){
        self.scanRect = rect
        super.init(frame: UIScreen.main.bounds)
        backgroundColor  = UIColor.clear
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    
    override func draw(_ rect: CGRect) {
        // Drawing code
        let ctx = UIGraphicsGetCurrentContext()!
        UIColor.black.withAlphaComponent(0.5).setFill()
        
        let screenPath =  CGMutablePath()
        screenPath.addRect(bounds)
        
        
        let scanPath = CGMutablePath();
        scanPath.addRect(scanRect)
        
        let path = CGMutablePath();
        path.addPath(screenPath)
        path.addPath(scanPath)
        
        
        ctx.addPath(path);
        ctx.drawPath(using: .eoFill)


        
    }
    

}
